import { prop_cur_req_user_identity } from '../../../../../../../Classes/cla_req_cur_headers_info';
import { get_mdb_cur_user_functions_active } from '../../create/Func/Sign_identity/Func/get_mdb_path_cur_user_functions';
import { req_info_cur_user_function_delete } from '../Classes/cla_req_info_cur_user_function_delete';

/**
 * 移除 当前 用户 的 函数创立 记录
 */
export async function sign_out_mdb_cur_user_function_identity(
  cur_req_info: req_info_cur_user_function_delete
) {
  let mdb_path_active = get_mdb_cur_user_functions_active(
    cur_req_info[prop_cur_req_user_identity]
  );

  let deleted_id_arr: string[] = [];

  for (const cur_delete_id of cur_req_info.delete_func_id_arr) {
    let cur_deleted_info = await mdb_path_active.deleteOne({
      id: cur_delete_id,
    });

    if (cur_deleted_info.acknowledged) {
      deleted_id_arr.push(cur_delete_id);
    }
  }

  return deleted_id_arr;
}
